fig.path <- "results/graph/"
fig.name <- "app_fig_f01.pdf"

newsdb <- read.csv("data/newspapers/mentions_elections_monthly.csv")

newsdb$start2 <- dmy(newsdb$start)
newsdb$end2 <- dmy(newsdb$end)

x1 <- ymd("1913-06-18") 
x2 <- ymd("1913-07-25")

e1 <- ymd("1913-02-15") 
e2 <- ymd("1913-03-31")

kol <- ghibli_palette(name = "PonyoMedium")[c(1,3,4)]

p <- ggplot(data = newsdb ) + 
   geom_rect( aes(xmin=e1, 
        xmax=e2, ymin=0, ymax=1280),
        alpha=0.01,
        fill = kol[2],
        inherit.aes = FALSE) +
    geom_text(aes(label = "Elections", 
        x = e1, y = 1000, 
        hjust =  1.2), col = kol[2])+
    geom_rect( aes(xmin=x1, 
        xmax=x2, ymin=0, ymax=1280),
            fill=kol[3],
            alpha=0.01,
            inherit.aes = FALSE) +
    geom_text(aes(label = "Pilgrimage", 
    x = x1, y = 1000, 
    hjust = -0.4), col = kol[3])+
  geom_line(aes(x = start2, y = nb_articles), col = kol[1]) +
  geom_point(aes(x = start2, y = nb_articles), col = kol[1]) +
  scale_x_date(date_breaks = "6 months",
               date_minor_breaks = "1 month") +
  theme_light(base_size = 16) + 
  labs( x = "Date" , y = "# Articles on Council Elections in Month")
ggsave(plot = p , paste0(fig.path, fig.name), width = 8, height = 5)
rm(list=   
    setdiff(ls()[sapply(ls(), function(x) any(class(get(x)) == 'data.frame'))],
    c("Re","Ind")))
